package ua.at.tsvetkov.samizdat.broadcastReceivers;

import ua.at.tsvetkov.samizdat.Const;
import ua.at.tsvetkov.samizdat.services.SrvUpdate;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.WifiManager;

public class BrSamizdat extends BroadcastReceiver {
	@Override
	public void onReceive(Context context, Intent intent) {
		String alarmManagerLaunch = intent.getStringExtra(Const.ALARM_MANAGER_LAUNCH);
		
		WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); 
		if(!wifiManager.isWifiEnabled()){
			wifiManager.setWifiEnabled(true);
		}
		
		if(alarmManagerLaunch != null && alarmManagerLaunch.equals(Const.ALARM_MANAGER_LAUNCH)){
			context.startService(new Intent(context, SrvUpdate.class));
		}
	}
}
